import request from "../utils/axios";

export function getRoutes() {
  return request({
    url: "/vue-element-admin/routes",
    method: "get",
  });
}

export function getRoles() {
  return request({
    url: "/vue-element-admin/roles",
    method: "get",
  });
}

export function getPageRolesApi(data: any) {
  return request({
    url: "/admin/system/sysRole/findByPage",
    method: "post",
    data,
  });
}

export function addRole(data: any) {
  return request({
    url: "/admin/system/sysRole/save",
    method: "post",
    data,
  });
}

export function updateRole(data: any) {
  return request({
    url: `/admin/system/sysRole/updateSysRole`,
    method: "put",
    data,
  });
}

export function deleteRole(id: number) {
  return request({
    url: `/admin/system/sysRole/deleteById/${id}`,
    method: "delete",
  });
}
export function findAllRoles() {
  return request({
    url: `/admin/system/sysRole/findAllRoles`,
    method: "get",
  });
}

export function findRoleByUserId(userId: number) {
  return request({
    url: `/admin/system/sysRole/findRoleByUserId?userId=${userId}`,
    method: "get",
  });
}
